package com.zzl.finance.data.constant;

import com.zzl.finance.data.dto.KeyValueDto;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务方式 1 无追索权
 *
 * @author : gull
 * @date : 2022/2/16 15:02
 */
public enum BusinessModeEnum {
    /**
     * 自建
     */
    BUSINESS_MODE_NO_RECOURSE(1, "无追索权");


    private final Integer code;
    private final String value;


    BusinessModeEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static String getValue(Integer code) {
        for (BusinessModeEnum statusEnum : BusinessModeEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.value;
            }
        }
        return "";
    }

    /**
     * 下拉框查询业务方式列表
     */
    public static List<KeyValueDto> getBusinessModeList() {
        List<KeyValueDto> list = new ArrayList<>();
        for (BusinessModeEnum statusEnum : BusinessModeEnum.values()) {
            KeyValueDto keyValueDto = new KeyValueDto();
            keyValueDto.setCode(statusEnum.code);
            keyValueDto.setValue(statusEnum.value);
            list.add(keyValueDto);
        }
        return list;
    }


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }
}
